//
//  LeInput.cpp
//  Leste
//
//  Created by 王乐 on 2022/1/24.
//

#include "LeInput.h"
#include "LeScreenSettings.h"

GLFWwindow* LeInput::window = nullptr;
double LeInput::dMouseX = SCR_WIDTH / 2;
double LeInput::dMouseY = SCR_HEIGHT / 2;
double LeInput::dScrollXOffset = 0;
double LeInput::dScrollYOffset = 0;

LeInput::LeInput() {
}

LeInput::~LeInput() { 
}

void LeInput::mouse_callback(double xpos, double ypos) { 
    dMouseX = xpos;
    dMouseY = ypos;
}

void LeInput::scroll_callback(double xoffset, double yoffset) {
    dScrollXOffset = xoffset;
    dScrollYOffset = yoffset;
}

int LeInput::getKey(int key) {
    if(window)
        return glfwGetKey(window, key);
    else
        return -1;
}

double LeInput::getMouseX() { 
    return dMouseX;
}

double LeInput::getMouseY() { 
    return dMouseY;
}

double LeInput::getScrollXOffset() { 
    return dScrollXOffset;
}

double LeInput::getScrollYOffset() { 
    return dScrollYOffset;
}

int LeInput::getMouseButton(int mousebutton)
{
    if(window)
    {
        int mouse = glfwGetMouseButton(window, mousebutton);
        return mouse;
    }
    else
        return -1;
}


